import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { param } from '@/utils/index'

// 获取任务列表
export function pagingTaskInfoDTO(query) {
  return request({
    url: '/project/taskInfo/pagingTaskInfoDTO',
    method: 'get',
    params: query
  })
}

// 获取支付列表
export function pagingTaskCommission(query) {
  return request({
    url: '/project/taskCommission/pagingTaskCommission',
    method: 'get',
    params: query
  })
}

// 财务追加酬金待托管 分页
export function pagingAppendAmount(query) {
  return request({
    url: '/project/taskCommission/pagingAppendAmount',
    method: 'get',
    params: query
  })
}
// 检测用户是否已付款
export function checkPayment(id, confirmType) {
  return request({
    url: '/project/taskCommission/checkPayment',
    method: 'post',
    params: { id: id, confirmType: confirmType }
  })
}
// 项目确认打款
export function confirmPayment(taskDetail) {
  return request({
    url: '/project/taskDetail/updateConfirmPayment',
    method: 'post',
    params: taskDetail
  })
}

// 追加酬金确认打款
export function confirmPaymentAppend(taskCommissionId) {
  return request({
    url: '/project/taskCommission/confirmPaymentAppend',
    method: 'post',
    params: { taskCommissionId }
  })
}
// 追加酬金打款扫码
export function paymentAppendScan(params) {
  return request({
    url: '/project/taskCommission/paymentAppendScan',
    method: 'post',
    params
  })
}

// 任务追加酬金
export function residuals(taskCommission) {
  return request({
    url: '/project/taskCommission/addResiduals',
    method: 'post',
    params: taskCommission
  })
}

// 任务验收
export function checkAcceptance(taskCommissionDTO) {
  return request({
    url: '/project/taskCommission/checkAcceptance',
    method: 'post',
    params: taskCommissionDTO
  })
}
// 任务记件验收通过
export function doPieceworkPass(taskCommissionId, number, taskId, enterpriseId) {
  const param = {
    taskCommissionId: taskCommissionId,
    number: number,
    taskId: taskId,
    enterpriseId: enterpriseId
  }
  return request({
    url: '/project/taskCommission/doPieceworkPass',
    method: 'post',
    params: param
  })
}

// 统计
export function countTaskDetail(taskId) {
  return request({
    url: '/project/taskDetail/countTaskDetail',
    method: 'get',
    params: { taskId }
  })
}

// 获取任务微客集合
export function getMemberListByTaskId(taskId) {
  return request({
    url: '/project/taskMember/getMemberListByTaskId',
    method: 'get',
    params: { taskId }
  })
}

// 获取源文件列表
export function pagingTaskFile(query) {
  return request({
    url: '/project/taskFile/paging',
    method: 'get',
    params: query
  })
}

// 获取规则列表
export function listTaskCommissionRule(taskCommissionId) {
  return request({
    url: '/project/taskCommission/listTaskCommissionRule',
    method: 'get',
    params: { taskCommissionId }
  })
}

// 查询等级集合
export function listTaskLevel(taskId, positionId) {
  const param = {
    taskId: taskId,
    positionId: positionId
  }
  return request({
    url: '/project/taskLevel/listTaskLevel',
    method: 'get',
    params: param
  })
}

// 查询该会员任务折扣
export function getTaskDetailDTO(taskId) {
  return request({
    url: '/project/taskDetail/getTaskDetail',
    method: 'get',
    params: { taskId }
  })
}

// 验收记录批量操作
export function bacthByPaymentStatus(taskCommissionList) {
  return request({
    url: '/project/taskCommission/bacthByPaymentStatus',
    method: 'post',
    data: taskCommissionList
  })
}

// 批量导出
export function exportBacth(query) {
  return process.env.BASE_API + '/project/taskCommission/exportBacth?' + param(query) + '&accessToken=' + getToken()
}

// 导入验收
export function uploadFiles(taskId) {
  return request({
    url: '/project/taskCommission/uploadFiles',
    method: 'post',
    params: { taskId }
  })
}

// 获取微客任务详情
export function getTaskCommissionMember(taskCommissionId) {
  return request({
    url: '/project/taskCommission/getTaskCommissionMember',
    method: 'get',
    params: { taskCommissionId }
  })
}
